//
//  FIBaseRequest.m
//  Magpie
//
//  Created by 100TV protocal on 12-11-14.
//
//

#import "FIBaseRequest.h"

@implementation FIBaseRequest

-(void) internalInit{
	
}

-(id) initWithTarget:(id) atarget action:(SEL) aaction {
	self=[super init];
	if(self){
		[self setTarget:atarget];
		[self setAction:aaction];
		m_params=[[NSMutableDictionary alloc] init];
		[self internalInit];
	}
	return self;
}

-(id) initWithTarget:(id) atarget action:(SEL) aaction params:(NSDictionary*) aparams{
	self=[super init];
	if(self){
		[self setTarget:atarget];
		[self setAction:aaction];
		m_params=[[NSMutableDictionary alloc] init];
		[m_params addEntriesFromDictionary:aparams];
		[self internalInit];
	}
	return self;
}

-(void) dealloc{
	[m_target release];
	[m_params release];
	[super dealloc];
}

-(void) setTarget:(id)atarget{
	id oldTarget=m_target;
	m_target=[atarget retain];
	[oldTarget release];
}
-(id) target{
	return m_target;
}
-(void) setAction:(SEL)aaction{
	m_action=aaction;
}
-(SEL) action{
	
	return m_action;
}
-(void) setParams:(NSDictionary *)aparams{
	[m_params removeAllObjects];
	[m_params addEntriesFromDictionary:aparams];
}

-(NSDictionary *) params{
	return m_params;
}

-(id) parseResponse:(id)reponse{
	return nil;
}

-(void) setParam:(id) param forKey:(id)key{
	assert(key!=nil);
	if(param==nil){
		[m_params removeObjectForKey:key];
	}else{
		[m_params setObject:param forKey:key];
	}
}
-(id) paramForKey:(id)key{
	return [m_params objectForKey:key];
}

@end
